package my.xh.validate.handler;

import my.xh.validate.ValidateField;
import org.springframework.util.StringUtils;

import java.util.Map;

public interface ValidateHandler {
  /** @MethodName validate
    * @Description  根据注解validateField的值校验参数paramName:paramValue，将结果放进map集合中。没有通过验证时，返回false,否则返回 与入参flag的或运算结果
    * @Param [validateField, paramName, paramValue, map]
    * @return void
    * @Author xuanhu
    * @Date 2019/1/17 14:50
   **/
    public boolean validate(ValidateField validateField,StringBuilder paramName,Object paramValue,Map<String,Object> map,boolean flag);
    /**
     * @Author xh
     * @Description 返回消息的处理
     * @Date 17:27 2019/9/3
     * @Param [validateField, msg]
     * @return java.lang.String
     **/
    default public String getMsg(ValidateField validateField,String msg) {
        if(StringUtils.isEmpty(validateField.msg())) return msg;
        return validateField.msg();
    }
}
